import React from 'react'
import PropTypes from 'prop-types'

import PieChartComponent from './PieChartComponent'
import BarChartComponent from './BarChartComponent'
import LineChartComponent from './LineChartComponent'
import CommonChartComponent from './CommonChartComponent'
import Common2ChartComponent from './Common2ChartComponent'
import BarHorizontalChartComponent from './BarHorizontalChartComponent'

class EchartsComponent extends React.Component {
    static defaultProps = {
        dataSource: [],
        columns: {},
    }

    render(){
        const { type, columns, color, dataSource, other } = this.props;
        if (type === 'Pie') return <PieChartComponent columns={columns} dataSource={dataSource} color={color} other={other}/>
        if (type === 'Bar') return <BarChartComponent columns={columns} dataSource={dataSource} color={color}/>
        if (type === 'Line') return <LineChartComponent columns={columns} dataSource={dataSource} color={color}/>
        if (type === 'Common') return <CommonChartComponent columns={columns} dataSource={dataSource} color={color} other={other}/>
        if (type === 'Common2') return <Common2ChartComponent columns={columns} dataSource={dataSource} color={color} other={other}/>
        if (type === 'BarHorizontal') return <BarHorizontalChartComponent columns={columns} dataSource={dataSource} color={color}/>
        return <PieChartComponent columns={columns} dataSource={dataSource} />
    }
}

EchartsComponent.propTypes = {
  type: PropTypes.string,
  dataSource: PropTypes.oneOfType([
    PropTypes.array,
    PropTypes.object,
  ]),
  columns: PropTypes.object,
}

export default EchartsComponent
